<template>

	<view class="container">
		<div class="message">
			<!-- 	<view :style="{ height: height + 'px' }">
				<view style="font-size: 36rpx;padding-left: 20rpx;"
					:style="{lineHeight: (height-menuHeight)+'px','paddingTop':menuHeight+'px'}">系统消息</view>
			</view> -->
			<!-- <view class="header-title">
				<view class="h-title">消息</view>
			</view> -->
			<!-- 	<div style="display: flex;justify-content: center;">
				<u-tabs :list="list" :is-scroll="false" :bold='true' :current="current" @click="change"></u-tabs>
			</div> -->
			<view class="list-box" v-if='current===0'>
				<view class="item-box" @click="messageClick(item.id)" v-for='item in appMessageList' :key='item.id'>
					<view class="left-img">
						<img :src="item.img" alt="" srcset="">
					</view>
					<view class="right-box">
						<view class="h-box">{{item.name}}</view>
						<view class="p-box" v-if='item.notViewedCount==0'>您没有未读消息</view>
						<view v-else class="p-box ">您有 <text class="no-box">{{item.notViewedCount}}</text> 条未读消息</view>
					</view>
				</view>

			</view>

		</div>

	</view>
</template>

<script>
	import {
		appMessageList
	} from '@/api/axios/Message.js'
	export default {
		props: {
			height: {
				type: Number,
				require: true,
			},
			menuHeight: {
				type: Number,
			}
		},
		data() {
			return {
				list: [{
					name: '系统消息'
				}],
				current: 0,
				baseURL: this.staticURL,
				appMessageList: []
			}
		},
		methods: {
			change(index) {
				this.current = index.index;
			},
			messageClick(index) {
				uni.navigateTo({
					url: '/pages/MessageDaily/index?index=' + index
				})
			},

		},
		async created() {
			let openId = uni.getStorageSync('openId')
			let customerId = uni.getStorageSync('customerId')
			this.appMessageList = await appMessageList({
				params: {
					openId,
					customerId
				}
			})
			this.appMessageList = this.appMessageList.map(item => {
				if (item.id === 1) {
					item.img = this.baseURL + '/static/message/icon_huodong.png'
				} else if (item.id === 2) {
					item.img = this.baseURL + '/static/message/icon_yuyue.png'
				}
				return item
			})
		}

	}
</script>

<style lang="scss">
	@import 'index.scss'
</style>